//q10.cpp
//This program takes an array and it size and return the highest value
//
//Binyamin 18 Jan 2018
//---------------------------------------------------------------------

#include<iostream>

using namespace std;

//get_max_squences_in_dec_seq
//input: an array and it size
//output: the highest value
int get_max_squences_in_dec_seq(int arr[], int size)
{
	int index; //current location
	int previous; //previous selection
	index = size/2 - 1;
	while(index != previous)
	{
		previous = index;
		if(arr[index] < arr[index + 1]) index++;
		else if (arr[index] < arr[index - 1]) index--;
	}
	return arr[index];
}

//1. generate an array
//2. print the highest value
int main()
{
	int arr[] = {13, 19, 23, 17, 16, 14, 8}; // test array
	cout << "The highest value of the array " << get_max_squences_in_dec_seq(arr, 7) << endl;
}
//output
//The highest value of the array 23
